package pl.edu.agh.winmon.hibernate;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Table(name = "`" + ProcessStatEntry.TABLE_NAME + "`")
public class ProcessStatEntry implements Serializable {

	@Transient
	private static final long serialVersionUID = 542250197776331135L;

	/**
	 * Table name.
	 */
	@Transient
	public static final String TABLE_NAME = "process_stat_entry"; //$NON-NLS-1$

	/**
	 * Hibernate's annotation property: id.
	 */
	@Transient
	public static final String PROP_ID = "id"; //$NON-NLS-1$

	/**
	 * Database column name: id;
	 */
	@Transient
	public static final String DB_ID = PROP_ID;

	/**
	 * Hibernate's annotation property: turn id.
	 */
	@Transient
	public static final String PROP_TURN = "turn"; //$NON-NLS-1$

	/**
	 * Database column name: turn id;
	 */
	@Transient
	public static final String DB_TURN = "turn_id"; //$NON-NLS-1$

	@Transient
	public static final String PROP_PROCESS = "process"; //$NON-NLS-1$

	@Transient
	public static final String DB_PROCESS = "process_id"; //$NON-NLS-1$

	@Transient
	public static final String PROP_LAST_TIME = "lastTime"; //$NON-NLS-1$

	@Transient
	public static final String DB_LAST_TIME = "last_time"; //$NON-NLS-1$

	@Transient
	public static final String PROP_CPU_USAGE = "cpuUsage"; //$NON-NLS-1$

	@Transient
	public static final String DB_CPU_USAGE = "cpu_usage"; //$NON-NLS-1$

	@Transient
	public static final String PROP_CPU_KERNEL_TIME = "cpuKernelTime"; //$NON-NLS-1$

	@Transient
	public static final String DB_CPU_KERNEL_TIME = "cpu_kernel_time"; //$NON-NLS-1$

	@Transient
	public static final String PROP_CPU_TOTAL_TIME = "cpuTotalTime"; //$NON-NLS-1$

	@Transient
	public static final String DB_CPU_TOTAL_TIME = "cpu_total_time"; //$NON-NLS-1$

	@Transient
	public static final String PROP_CPU_USER_TIME = "cpuUserTime"; //$NON-NLS-1$

	@Transient
	public static final String DB_CPU_USER_TIME = "cpu_user_time"; //$NON-NLS-1$

	@Transient
	public static final String PROP_FILE_DESCRIPTORS = "fileDescriptors"; //$NON-NLS-1$

	@Transient
	public static final String DB_FILE_DESCRIPTORS = "file_descriptors"; //$NON-NLS-1$

	@Transient
	public static final String PROP_MEMORY_MAJOR_FAULTS = "memoryMajorFaults"; //$NON-NLS-1$

	@Transient
	public static final String DB_MEMORY_MAJOR_FAULTS = "memory_major_faults"; //$NON-NLS-1$

	@Transient
	public static final String PROP_MEMORY_MINOR_FAULTS = "memoryMinorFaults"; //$NON-NLS-1$

	@Transient
	public static final String DB_MEMORY_MINOR_FAULTS = "memory_minor_faults"; //$NON-NLS-1$

	@Transient
	public static final String PROP_MEMORY_PAGE_FAULTS = "memoryPageFaults"; //$NON-NLS-1$

	@Transient
	public static final String DB_MEMORY_PAGE_FAULTS = "memory_page_faults"; //$NON-NLS-1$

	@Transient
	public static final String PROP_TOTAL_RESIDENT_MEMORY = "totalResidentMemory"; //$NON-NLS-1$

	@Transient
	public static final String DB_TOTAL_RESIDENT_MEMORY = "total_resident_memory"; //$NON-NLS-1$

	@Transient
	public static final String PROP_TOTAL_SHARED_MEMORY = "totalSharedMemory"; //$NON-NLS-1$

	@Transient
	public static final String DB_TOTAL_SHARED_MEMORY = "total_shared_memory"; //$NON-NLS-1$

	@Transient
	public static final String PROP_TOTAL_VIRTUAL_MEMORY = "totalVirtualMemory"; //$NON-NLS-1$

	@Transient
	public static final String DB_TOTAL_VIRTUAL_MEMORY = "total_virtual_memory"; //$NON-NLS-1$

	@Transient
	public static final String PROP_USED_PROCESSORS = "usedProcessors"; //$NON-NLS-1$

	@Transient
	public static final String DB_USED_PROCESSORS = "used_processors"; //$NON-NLS-1$

	@Transient
	public static final String PROP_ACTIVE_THREADS = "activeThreads"; //$NON-NLS-1$

	@Transient
	public static final String DB_ACTIVE_THREADS = "active_threads"; //$NON-NLS-1$

	/**
	 * Id.
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = DB_ID)
	private Long id;

	/**
	 * Turn of collected data.
	 */
	@ManyToOne
	@JoinColumn(name = DB_TURN)
	private Turn turn;

	@ManyToOne
	@JoinColumn(name = DB_PROCESS)
	private Process process;

	@Column(name = DB_LAST_TIME)
	private Long lastTime = -1L;

	@Column(name = DB_CPU_USAGE)
	private Double cpuUsage = -1.0;

	@Column(name = DB_CPU_KERNEL_TIME)
	private Long cpuKernelTime = -1L;

	@Column(name = DB_CPU_TOTAL_TIME)
	private Long cpuTotalTime = -1L;

	@Column(name = DB_CPU_USER_TIME)
	private Long cpuUserTime = -1L;

	@Column(name = DB_FILE_DESCRIPTORS)
	private Long fileDescriptors = -1L;

	@Column(name = DB_MEMORY_MAJOR_FAULTS)
	private Long memoryMajorFaults = -1L;

	@Column(name = DB_MEMORY_MINOR_FAULTS)
	private Long memoryMinorFaults = -1L;

	@Column(name = DB_MEMORY_PAGE_FAULTS)
	private Long memoryPageFaults = -1L;

	@Column(name = DB_TOTAL_RESIDENT_MEMORY)
	private Long totalResidentMemory = -1L;

	@Column(name = DB_TOTAL_SHARED_MEMORY)
	private Long totalSharedMemory = -1L;

	@Column(name = DB_TOTAL_VIRTUAL_MEMORY)
	private Long totalVirtualMemory = -1L;

	@Column(name = DB_USED_PROCESSORS)
	private Integer usedProcessors = -1;

	@Column(name = DB_ACTIVE_THREADS)
	private Long activeThreads = -1L;

	/**
	 * Returns Id.
	 * 
	 * @return Id.
	 */
	public Long getId() {
		return id;
	}

	/**
	 * Sets Id.
	 * 
	 * @param id
	 *            Id.
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * Returns turn of collected data.
	 * 
	 * @return Turn of collected data.
	 */
	public Turn getTurn() {
		return turn;
	}

	/**
	 * Set turn of collected data.
	 * 
	 * @param turn
	 *            Turn of collected data.
	 */
	public void setTurn(Turn turn) {
		this.turn = turn;
	}

	public Process getProcess() {
		return process;
	}

	public void setProcess(Process process) {
		this.process = process;
	}

	public Long getLastTime() {
		return lastTime;
	}

	public void setLastTime(Long lastTime) {
		this.lastTime = lastTime;
	}

	public Double getCpuUsage() {
		return cpuUsage;
	}

	public void setCpuUsage(Double cpuUsage) {
		this.cpuUsage = cpuUsage;
	}

	public Long getCpuKernelTime() {
		return cpuKernelTime;
	}

	public void setCpuKernelTime(Long cpuKernelTime) {
		this.cpuKernelTime = cpuKernelTime;
	}

	public Long getCpuTotalTime() {
		return cpuTotalTime;
	}

	public void setCpuTotalTime(Long cpuTotalTime) {
		this.cpuTotalTime = cpuTotalTime;
	}

	public Long getCpuUserTime() {
		return cpuUserTime;
	}

	public void setCpuUserTime(Long cpuUserTime) {
		this.cpuUserTime = cpuUserTime;
	}

	public Long getFileDescriptors() {
		return fileDescriptors;
	}

	public void setFileDescriptors(Long fileDescriptors) {
		this.fileDescriptors = fileDescriptors;
	}

	public Long getMemoryMajorFaults() {
		return memoryMajorFaults;
	}

	public void setMemoryMajorFaults(Long memoryMajorFaults) {
		this.memoryMajorFaults = memoryMajorFaults;
	}

	public Long getMemoryMinorFaults() {
		return memoryMinorFaults;
	}

	public void setMemoryMinorFaults(Long memoryMinorFaults) {
		this.memoryMinorFaults = memoryMinorFaults;
	}

	public Long getMemoryPageFaults() {
		return memoryPageFaults;
	}

	public void setMemoryPageFaults(Long memoryPageFaults) {
		this.memoryPageFaults = memoryPageFaults;
	}

	public Long getTotalResidentMemory() {
		return totalResidentMemory;
	}

	public void setTotalResidentMemory(Long totalResidentMemory) {
		this.totalResidentMemory = totalResidentMemory;
	}

	public Long getTotalSharedMemory() {
		return totalSharedMemory;
	}

	public void setTotalSharedMemory(Long totalSharedMemory) {
		this.totalSharedMemory = totalSharedMemory;
	}

	public Long getTotalVirtualMemory() {
		return totalVirtualMemory;
	}

	public void setTotalVirtualMemory(Long totalVirtualMemory) {
		this.totalVirtualMemory = totalVirtualMemory;
	}

	public Integer getUsedProcessors() {
		return usedProcessors;
	}

	public void setUsedProcessors(Integer usedProcessors) {
		this.usedProcessors = usedProcessors;
	}

	public Long getActiveThreads() {
		return activeThreads;
	}

	public void setActiveThreads(Long activeThreads) {
		this.activeThreads = activeThreads;
	}

}
